package com.ethanzzh.security.ethanzzhdemo.dto;

import com.ethanzzh.security.ethanzzhdemo.validator.MyConstraint;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.NotBlank;


import javax.validation.constraints.Past;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class User {

    public interface UserSimpleView{};

    public interface UserDatailView extends UserSimpleView {};

    private String id;


    @MyConstraint(message = "这是一个测试")
    private String username;

    @NotBlank(message = "密码不能为空")
    private String password;

    @Past(message = "生日必须是过去的时间")
    private Date birthday;

    //JsonView 可以有选择性的序列化对象
    @JsonView(User.UserSimpleView.class)
    public String getUsername() {
        return username;
    }


    @JsonView(User.UserDatailView.class)
    public String getPassword() {
        return password;
    }

    @JsonView(User.UserSimpleView.class)
    public Date getBirthday() {
        return birthday;
    }
}
